import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
// import fastclick from "fastclick";
import VueLazyload from "vue-lazyload";
import Vant from "vant";
import Element from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "vant/lib/index.css";
import "@/common/js/flexible.js";
import "@/common/scss/index.scss";
import api from "@/api/api.js";
import VueI18n from "vue-i18n";
import zh from "@/common/lang/zh";
import en from "@/common/lang/en";
import VueCookies from "vue-cookies";
Vue.use(VueCookies);

import VConsole from "vconsole";
if (process.env.NODE_ENV == "development") {
	const vConsole = new VConsole();
}

Vue.prototype.$api = api;
Vue.config.productionTip = false;

// fastclick.attach(document.body);

Vue.use(Vant);
Vue.use(Element);

Vue.use(VueLazyload, {
	loading: require("@/assets/logo.png"),
});
Vue.use(VueI18n);
const i18n = new VueI18n({
	//locale: localStorage.getItem('language')||'zh', //使用localStorage缓存到本地，当下次使用时可默认当前使用语言
	locale: localStorage.getItem("_lang_type_") || "en",
	messages: {
		zh: zh, // 中文语言包
		en: en, // 英文语言包
	},
});

Vue.directive("clickoutside", {
	bind: function(el) {
		let dom = el.querySelector(".el-input__inner");
		// dom.removeAttribute("readonly");
		setTimeout(() => {
			dom.removeAttribute("readonly");
		}, 200);
		dom.addEventListener("blur", function() {
			setTimeout(() => {
				dom.removeAttribute("readonly");
			}, 200);
		});
	},
});

const vue = new Vue({
	router,
	store,
	i18n,
	render: (h) => h(App),
	beforeCreate() {
		Vue.prototype.$bus = this;
	},
}).$mount("#app");
window.vue = vue;
